@extends('layout.layout')
@section('content')
    <h1 class="page-title">充值卡管理 <small></small></h1>
            <div class="row-fluid">
                <div class="span12">
                    <div class="widget">
                    <div class="widget">
                        <div class="widget-header">
                            <h4>充值卡列表</h4>
 
                        </div>
                        <div class="widget-content">
                        <div class="row-fluid">
                           <div class="span6">
                           <form action="">
                            <div class="dataTables_length" id="data-table_length">
                             <label><select aria-controls="data-table" size="1" name="num" style="background: rgba(0,0,0,0.5)">
                             <option value="10" >10</option>
                             <option value="25" >25</option>
                             <option value="50" >50</option>
                             </select>每页显示条数</label>
                            </div>
                           </div>
                           <div class="span6">
                            <div id="data-table_filter" class="dataTables_filter">
                             <label>面额: <input name="keywords" value="@if(!empty($request['keywords'])){{$request['keywords']}}@endif" aria-controls="data-table" type="text" />
                             <button class="btn btn-primary icon-search" type="submit" style="position:relative;bottom:4px;">查询</button>
                             </label>
                            </div>
                           </div>
                           <input type="hidden" name="_token" value="{{csrf_token()}}"/>
                           </form>
                          </div>
                            <table class="table table-striped table-bordered">
                                <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th class="hidden-phone">序列号</th>
                                        <th class="hidden-phone" style="width: 150px;">密码</th>
                                        <th class="hidden-phone" style="width: 80px;">面额</th>
                                        <th class="hidden-phone" style="width: 150px;" >生成时间</th>
                                        <th class="hidden-phone" style="width: 100px;" >状态</th>
                                        <th style="width: 111px;">操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    
                                    <tr class="odd gradeX">
                                        @foreach($data as $k=>$v)
                                        <td class="sid">{{$v->id}}</td>
                                        <td class="hidden-phone">{{$v->number}}</td>
                                        <td class="hidden-phone">{{$v->password}}</td>
                                        <td class="hidden-phone"><span class="icon-dollar margin-left-5">{{$v->amount}}</span></td>
                                        <td class="hidden-phone">{{date('Y-m-d H:i:s',$v->time)}}</td>
                                        <td class="center hidden-phone">
                                            @if($v->status == 1)
                                            <span class="label label-success">未充值</span>
                                            @elseif($v->status == 2)
                                            <span class="label label-important">已充值</span>
                                            @endif
                                        </td>
                                        <td class="center hidden-phone">
                                        <span class="icon-remove label label-important">
                                        <a href = "" class="delete">删除</a>
                                        {{csrf_field()}}
                                        </span>
                                        &nbsp;&nbsp;
                                        <span class="icon-edit label label-success">
                                        <a href = ""></a> 
                                        </span>
                                        </td>
                                    </tr>
                                    @endforeach
                                </tbody>
                            </table>
                            <!-- 分页 -->
                            <div class="row-fluid">
                               <div class="span6">
                                <div id="data-table_info" class="dataTables_info padding-top-25">
                                 共&nbsp;<span class="badge badge-info">{!! $pays->total() !!}</span>&nbsp;条
                                </div>
                               </div>
                               <div class="span6">
                                <div class="dataTables_paginate paging_bootstrap pagination padding-bottom-20">
                                {!! $pays->appends($request)->render() !!}
                                </div>
                               </div>
                              </div>
                              <!-- 分页eend -->
                            <div class="clearfix"></div>
                        </div>
                    </div>
                    </div>
                </div><!-- end span12 -->
            </div><!-- end row-fluid -->
@endsection
    @section('myjs')
    <script type="text/javascript">
        $.ajaxSetup({
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
        }
        });
        $('.delete').click(function(){
            // alert('233');
            var id = $(this).parents('tr').find('.sid').html();
            // alert(id);p
            var dd = $(this);
            $.post('/admin/pay/delete',{id:id},function(data){
                // console.log(data);
                if(data == 1){
                   dd.parents('tr').remove();
                }else{
                    alert('失败!!');
                }
            })
            return false;
        })
    </script>
    @endsection